<template>
	<view class="details">
		<view class="title-box">
			<view class="title">{{ details && details.title }}</view>
			<view class="username">作者: {{ details && (details.nickname || details.username) }}</view>
		</view>
		<view class="container" v-if="details">
			<view class="content" v-html="details.content"></view>
		</view>
	</view>
</template>

<script>
	import { articleDetails } from '@/common/api.js'
	
	export default {
		data() {
			return {
				details: null
			}
		},
		onLoad(options) {
			const { title, id } = options
			uni.setNavigationBarTitle({ title })
			this._articleDetails(id)
		},
		methods: {
			_articleDetails(article_id) {
				uni.showLoading()
				articleDetails({ article_id }).then(({ code, data }) => {
					uni.hideLoading()
					if (code === 200) {
						this.details = data
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.username {
		font-size: 24rpx;
		color: #909399;
	}
	.title {
		font-size: 32rpx;
		margin-bottom: 8rpx;
		color: #303133;
	}
	.title-box {
		text-align: center;
		margin-bottom: 32rpx;
		background-color: #fff;
		border-radius: 8rpx;
		padding: 24rpx;
	}
	.container {
		padding: 24rpx;
		background-color: #fff;
		border-radius: 8rpx;
	}
	.details {
		padding: 24rpx;
	}
</style>
